<!--
  #%L
  thinkbig-ui-feed-manager
  %%
  Copyright (C) 2017 ThinkBig Analytics
  %%
  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
  #L%
  -->
<card-layout body-css="md-padding">

    <header-section>
        <div layout="row" layout-align="space-between-center" flex>
          <div class="card-title" flex>{{"views.define-feed-general-info.GeneralInfo" | translate}}</div>
          <h2 class="card-sub-header">{{::vm.stepNumber}} {{"views.define-feed-general-info.of" | translate}} {{::vm.totalSteps}}</h2>
        </div>
        <thinkbig-feed-errors-card-header></thinkbig-feed-errors-card-header>
    </header-section>

    <body-section md-content class="layout-padding-top">
<ng-form name="vm.defineFeedGeneralForm">
        <div layout="column">
                <div layout="row" layout-align="space-between start">
                    <md-input-container flex="45" class="condensed">
                        <label>{{"views.define-feed-general-info.DN" | translate}}</label>
                        <input required ng-model="vm.model.feedName" name="feedName" ng-disabled="vm.model.id != null"/>
                        <div ng-messages="vm.defineFeedGeneralForm.feedName.$error"  md-auto-hide="false">
                            <div ng-message="required">{{"views.define-feed-general-info.Req" | translate}}</div>
                          <div ng-message="notUnique"> {{"views.define-feed-general-info.AFeedWith" | translate}} </div>
                       </div>
                    </md-input-container>
                    <div flex="10"></div>
                    <md-input-container flex="45" class="condensed">
                        <label>{{"views.define-feed-general-info.SN" | translate}}</label>
                        <input  readonly ng-model="vm.model.systemFeedName"/>
                        <div class="hint">Auto generated from the feed display name</div>
                    </md-input-container>
                </div>
          <div layout="row" layout-align="space-between start">
                    <md-autocomplete flex="45" required ng-disabled="vm.model.id != null"
                                     md-input-name="category"
                            md-selected-item="vm.category"
                            md-search-text-change="vm.categorySearchTextChanged(vm.categorySearchText)"
                            md-search-text="vm.categorySearchText"
                            md-selected-item-change="vm.categorySelectedItemChange(item)"
                            md-items="item in vm.categoriesService.querySearch(vm.categorySearchText)"
                            md-item-text="item.name"
                            md-min-length="0"
                                     md-floating-label="{{'views.define-feed-general-info.Category' | translate}}"
                            md-menu-class="autocomplete-categories-template">
                        <md-item-template>
                  <span class="item-title" ng-class="item.createFeed ? '' : 'disabled'">
                       <ng-md-icon icon="{{item.icon}}" style="fill:{{item.iconColor}}" ng-if="item.createFeed"></ng-md-icon>
                    <ng-md-icon icon="block" class="disabled" ng-if="!item.createFeed"></ng-md-icon>
                    <span> {{item.name}} </span>
                  </span>
                  <span class="item-metadata">
                    <span class="item-metastat hint"  ng-if="item.createFeed">
                     {{item.description | characters:50}}
                    </span>
                  </span>
                        </md-item-template>
                        <md-not-found>
                            No categories matching "{{vm.categorySearchText}}" were found.
                        </md-not-found>
                      <div ng-messages="vm.defineFeedGeneralForm.category.$error">
                        <div ng-message="required">{{"views.define-feed-general-info.Req" | translate}}</div>
                        <div ng-message="accessDenied"> {{"views.define-feed-general-info.YouAreNot" | translate}} </div>
                      </div>
                  </md-autocomplete>
               </div>

                <md-input-container class="md-block condensed">
                    <label>{{"views.define-feed-general-info.Description" | translate}}</label>
                    <textarea ng-model="vm.model.description"></textarea>
                </md-input-container>

        </div>

       <thinkbig-step-buttons can-continue="vm.isValid &&  vm.defineFeedGeneralForm.$valid" step-index="{{::vm.stepIndex}}" ></thinkbig-step-buttons>
        </ng-form>
    </body-section>

</card-layout>

